import sys
import threading
import time

import keyboard  #监听键盘

def stop():
    global stop_flag
    stop_flag = True

def show():
    print("当前值：" + str(count))

def add():
    global count
    while True:
        count += 1
        print(count)
        if stop_flag:
            break
        time.sleep(1)

if __name__ == '__main__':
    count = 0
    stop_flag=False
    threading.Thread(target=add).start()
    keyboard.add_hotkey('ctrl+c', stop)
    keyboard.add_hotkey('left', show)
    keyboard.record(until='ctrl+c')
